using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;

namespace Scurvy.Media.Pipeline
{
    [ContentTypeWriter]
    internal class VideoInMemoryWriter : ContentTypeWriter<VideoContent>
    {
        public override string GetRuntimeReader(Microsoft.Xna.Framework.TargetPlatform targetPlatform)
        {
            return typeof(VideoInMemoryReader).AssemblyQualifiedName;
        }

        protected override void Write(ContentWriter output, VideoContent value)
        {
            output.Write(value.FrameRate);

            int count = value.Count;
            output.Write(count);
            for (int i = 0; i < count; i++)
            {
                output.WriteObject<Texture2DContent>(value[i]);
                value[i] = null;
            }
            value.Clear();
            value.Dispose();
        }
    }
}
